home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / DeveloperStax.cpt / Developer Stack 1.0 / card_4883.txt < prev    next >
Text File  |  1989-02-26  |  2KB  |  74 lines

  1. -- card: 4883 from stack: in.0
  2. -- bmap block id: 0
  3. -- flags: 4000
  4. -- background id: 2202
  5. -- name: LastPathComponent
  6.  
  7.  
  8. -- part contents for background part 2
  9. ----- text -----
  10. --
  11. -- LastPathComponent -- given a file pathname, returns the last
  12. -- component i.e. whatever comes after the last colon, if anything.
  13. -- From Dewi Williams
  14. --
  15. function LastPathComponent name
  16.   -- scan backwards for the last colon.
  17.   repeat with i = the length of name down to 1
  18.     if character i of name is ":" then exit repeat
  19.   end repeat
  20.   
  21.   if i is 1 then
  22.     -- Name was of the form ":thing" or "thing". Check for leading
  23.     -- colon, and adjust if necessary. Done for generality.
  24.     if first character of name is ":" then
  25.       put 2 into i
  26.     end if
  27.   else
  28.     add 1 to i -- skip the colon
  29.   end if
  30.   
  31.   -- Name was of the form "Thing:otherthing". Return "otherThing".
  32.   put empty into lastpath
  33.   repeat with j = i to the length of name
  34.     put character j of name after lastpath
  35.   end repeat
  36.   return lastpath
  37. end LastPathComponent
  38. --
  39. -- LastPathComponent -- given a file pathname, returns the last
  40. -- component i.e. whatever comes after the last colon, if anything.
  41. -- From Dewi Williams
  42. --
  43. function LastPathComponent name
  44.   -- scan backwards for the last colon.
  45.   repeat with i = the length of name down to 1
  46.     if character i of name is ":" then exit repeat
  47.   end repeat
  48.   
  49.   if i is 1 then
  50.     -- Name was of the form ":thing" or "thing". Check for leading
  51.     -- colon, and adjust if necessary. Done for generality.
  52.     if first character of name is ":" then
  53.       put 2 into i
  54.     end if
  55.   else
  56.     add 1 to i -- skip the colon
  57.   end if
  58.   
  59.   -- Name was of the form "Thing:otherthing". Return "otherThing".
  60.   put empty into lastpath
  61.   repeat with j = i to the length of name
  62.     put character j of name after lastpath
  63.   end repeat
  64.   return lastpath
  65. end LastPathComponent
  66.  
  67.  
  68. -- part contents for background part 3
  69. ----- text -----
  70. LastPathComponent
  71.  
  72. -- part contents for background part 10
  73. ----- text -----
  74. 1